import { listButtonInfo, listRecursiveMenuByBelong } from '@api/api-public.js'

// 获取页面按钮
async function getButtonList(belongPage) {
  const data = await listButtonInfo({ belongPage: belongPage })
  return data.data
}
// 获取页面菜单
async function getMenuList(belongPage) {
  const data = await listRecursiveMenuByBelong({ belongPage: belongPage })
  return data.data
}

// 判断是否有按钮权限
function hasPer(buttonList, menuCode) {
  const btnArr = buttonList.filter(item => item.menuCode === menuCode)
  if (btnArr.length > 0) {
    return btnArr[0]
  } else {
    return false
  }
}
export default {
  getButtonList: getButtonList,
  getMenuList: getMenuList,
  hasPer: hasPer,
}
